protocol under Windows that don't show up with efence on Linux.
2) Don't cross the ident and shortnames of the waypoints.
gpsapp.c) Correct loops for D108 and D109 that are looking at zero
terminated strings when its own doc says that the input is NOT
zero terminated strings. (Why am I rapidly losing faith in jeeps?)
gpsmem.c) Initialize several more waypoint fields on startup.
extern int32 gps_save_id;
int short_length;
- way = xmalloc(n*sizeof(*way));
+ way = xcalloc(n,sizeof(*way));
for (i = 0; i < n; i++) {
if(!((way)[i]=GPS_Way_New()))
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
waypoint *wpt;
char *ident;
- char *src;
+ char *src = NULL;
+ char *wptname;
wpt = (waypoint *) elem;
ident = global_opts.synthesize_shortnames ?
mkshort(src) :
wpt->shortname;
-
strncpy(way[i]->ident, ident, sizeof(way[i]->ident));
- if (wpt->description) {
- strncpy(way[i]->cmnt, wpt->description,
- sizeof(way[i]->cmnt));
- } else {
- way[i]->cmnt[0] = 0;
+ way[i]->ident[sizeof(way[i]->ident)-1] = 0;
+ if (src && strlen(src)) {
+ strncpy(way[i]->cmnt, src, sizeof(way[i]->cmnt));
}
way[i]->lon = wpt->position.longitude.degrees;
way[i]->lat = wpt->position.latitude.degrees;
- way[i]->alt = wpt->position.altitude.altitude_meters;
+ if (wpt->position.altitude.altitude_meters != unknown_alt) {
+ way[i]->alt = wpt->position.altitude.altitude_meters;
+ }
i++;
}
-
if ((ret = GPS_Command_Send_Waypoint(portname, way, n)) < 0) {
fatal(MYNAME ":communication error sending wayoints..\n");
}
q = (UC *) way->ident;
- while((*p++ = *q++));
+ i = sizeof(way->ident);
+ while((*p++ = *q++) && i--);
q = (UC *) way->cmnt;
- while((*p++ = *q++));
+ i = sizeof(way->cmnt);
+ while((*p++ = *q++) && i--);
q = (UC *) way->facility;
- while((*p++ = *q++));
+ i = sizeof(way->facility);
+ while((*p++ = *q++) && i--);
q = (UC *) way->city;
- while((*p++ = *q++));
+ i = sizeof(way->city);
+ while((*p++ = *q++) && i--);
q = (UC *) way->addr;
- while((*p++ = *q++));
+ i = sizeof(way->addr);
+ while((*p++ = *q++) && i--);
q = (UC *) way->cross_road;
- while((*p++ = *q++));
+ i = sizeof(way->cross_road);
+ while((*p++ = *q++) && i--);
*len = p-data;
int32 i;
p = data;
-
*p++ = 1 /* way->wpt_class */; /* For D109, the class must be 1 */
*p++ = 0 /* way->colour*/ ; /* If non-zero, the waypoint is in
invisible ink on the V. */
for(i=0;i<4;++i) *p++ = 0xff; /* D109 silliness for ETE */
q = (UC *) way->ident;
- while((*p++ = *q++));
+ i = sizeof(way->ident);
+ while((*p++ = *q++) && i--);
q = (UC *) way->cmnt;
- while((*p++ = *q++));
+ i = sizeof(way->ident);
+ while((*p++ = *q++) && i--);
q = (UC *) way->facility;
- while((*p++ = *q++));
+ i = sizeof(way->facility);
+ while((*p++ = *q++) && i--);
q = (UC *) way->city;
- while((*p++ = *q++));
+ i = sizeof(way->city);
+ while((*p++ = *q++) && i--);
q = (UC *) way->addr;
- while((*p++ = *q++));
+ i = sizeof(way->addr);
+ while((*p++ = *q++) && i--);
q = (UC *) way->cross_road;
- while((*p++ = *q++));
-
+ i = sizeof(way->cross_road);
+ while((*p++ = *q++) && i--);
*len = p-data;
-
return;
}
fflush(stderr);
return NULL;
}
-
- /* Mark all as "unused" */
+ /*
+ * Mark all as "unused". These appear in the same order as in struct.
+ * It's wretched that A) memset isn't used. B) sizeof isn't used. C)
+ * The whole stupid structure isn't simply memsetted sanely.
+ */
for(i=0;i<6;++i) ret->ident[i]=' ';
- for(i=0;i<2;++i) ret->cc[i]=' ';
- for(i=0;i<18;++i) ret->subclass[i]=' ';
for(i=0;i<40;++i) ret->cmnt[i]=' ';
+ for(i=0;i<256;++i) ret->wpt_ident[i]=' ';
+ for(i=0;i<256;++i) ret->lnk_ident[i]=' ';
+ for(i=0;i<18;++i) ret->subclass[i]=' ';
+ for(i=0;i<2;++i) ret->cc[i]=' ';
for(i=0;i<24;++i) ret->city[i]=' ';
for(i=0;i<2;++i) ret->state[i]=' ';
for(i=0;i<30;++i) ret->name[i]=' ';
+ for(i=0;i<32;++i) ret->facility[i]=' ';
+ for(i=0;i<52;++i) ret->addr[i]=' ';
+ for(i=0;i<52;++i) ret->cross_road[i]=' ';
+ for(i=0;i<20;++i) ret->rte_cmnt[i]=' ';
+ for(i=0;i<256;++i) ret->rte_ident[i]=' ';
for(i=0;i<18;++i) ret->rte_link_subclass[i]=' ';
- for(i=0;i<256;++i) ret->wpt_ident[i]=' ';
- for(i=0;i<256;++i) ret->lnk_ident[i]=' ';
for(i=0;i<256;++i) ret->rte_link_ident[i]=' ';
ret->dst = ret->lat = ret->lon = GPS_FLTMAX;